package com.lkm.app_ui.m.vip;

import com.lkm.app_ui.AppConst;
import com.lkm.frame.otto.LinkBus;
import com.lkm.frame.otto.LinkBusEventFlag;
import com.lkm.frame.otto.ThreadEnforcer;



public class OnVipEvent implements LinkBusEventFlag {

    public static void sending() {

        LinkBus.sendBroadcast(new OnVipEvent(1, null), null, true, AppConst.mainHandler);
    }

    public static void sendOK(VipInfo vipInfo) {
        LinkBus.sendBroadcast(new OnVipEvent(2, vipInfo), null, true, AppConst.mainHandler);
    }

    public static void sendFail(String error) {
        OnVipEvent onVipEvent = new OnVipEvent(3, null);
        onVipEvent.error = error;
        LinkBus.sendBroadcast(onVipEvent, null, true, AppConst.mainHandler);
    }




    private final int state;

    private String error;

    private final VipInfo vipInfo;


    private volatile boolean isIntercepted;


    public boolean isIntercepted() {
        return isIntercepted;
    }

    public void setIntercepted(boolean intercepted) {
        isIntercepted = intercepted;
    }

    

    public OnVipEvent(int state, VipInfo vipInfo) {
        this.state = state;
        this.vipInfo = vipInfo;
    }

    public boolean isIng() {
        return state == 1;
    }

    public boolean isOk() {
        return state == 2;
    }

    public boolean isFail() {
        return state == 3;
    }

    public VipInfo getVipInfo() {
        return vipInfo;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    @Override
    public ThreadEnforcer getThreadEnforcer() {
        return ThreadEnforcer.MAIN;
    }

    @Override
    public boolean isStickyBroadcast() {
        return true;
    }
}
